#include <bits/stdc++.h>
using namespace std;
int main() {
    int M;cin >> M;
    for (int i = 0; i < M; ++i) {
        int K;cin >> K;
        bool found = false;
        for (int N = 1; N < 10; ++N) {
            int result = N * K * K;
            string resultStr = to_string(result);
            string KStr = to_string(K);
            if (resultStr.size() >= KStr.size() &&
                resultStr.substr(resultStr.size() - KStr.size()) == KStr) {
                cout << N << " " << result << endl;
                found = true;
                break;
            }
        }
        if (!found) {
            cout << "No" << endl;
        }
    }
    return 0;
}